package tankgame;

import java.awt.*;

/**
 * @description:
 * @Author yyp
 * @time 2022/3/30
 */
public class Draw {

    public static void drawTank(int x, int y, Graphics g, int direct, int type){
        switch (type){
            case 0:
                g.setColor(Color.BLUE);
                break;
            case 1:
                g.setColor(Color.ORANGE);
                break;
        }

        switch (direct){
            case 0:
                g.fill3DRect(x-20, y-20, 20, 60, false);
                //画出坦克左边轮子
                g.fill3DRect(x + 20, y-20, 20, 60, false);
                //画出坦克右边轮子
                g.fill3DRect(x, y - 10, 20, 40, false);
                //画出坦克盖子
                g.fillOval(x, y, 20, 20);
                //画出圆形盖子
                g.drawLine(x + 10, y + 10, x + 10, y - 20);
                //画出炮筒
                break;
            case 1: //表示向右
                g.fill3DRect(x-20, y-20, 60, 20, false);
                //画出坦克上边轮子
                g.fill3DRect(x-20, y+20, 60, 20, false);
                //画出坦克下边轮子
                g.fill3DRect(x-10, y, 40, 20, false);
                //画出坦克盖子
                g.fillOval(x, y, 20, 20);
                //画出圆形盖子
                g.drawLine(x+10, y+10, x+40, y+10);
                //画出炮筒
                break;
            case 2: //表示向下
                g.fill3DRect(x-20, y-20, 20, 60, false);
                //画出坦克左边轮子
                g.fill3DRect(x + 20, y-20, 20, 60, false);
                //画出坦克右边轮子
                g.fill3DRect(x, y - 10, 20, 40, false);
                //画出坦克盖子
                g.fillOval(x, y, 20, 20);
                //画出圆形盖子
                g.drawLine(x+10, y+10, x+10, y+40);
                //画出炮筒
                break;
            case 3: //表示向左
                g.fill3DRect(x-20, y-20, 60, 20, false);
                //画出坦克上边轮子
                g.fill3DRect(x-20, y+20, 60, 20, false);
                //画出坦克下边轮子
                g.fill3DRect(x-10, y, 40, 20, false);
                //画出坦克盖子
                g.fillOval(x, y, 20, 20);
                //画出圆形盖子
                g.drawLine(x+10, y+10, x-20, y+10);
                //画出炮筒
                break;
            default:
                System.out.println("暂时没有处理");
        }
    }

    public static void drawBullet(int x, int y, int direct, int speed, Graphics g){
        switch (direct){
            case 0:
                g.fillOval(x + 10, y-20, 20, 20);
                break;
            case 1:
                g.fillOval(x + 60, y+10, 20, 20);
                break;
            case 2:
                g.fillOval(x +10, y+60, 20, 20);
                break;
            case 3:
                g.fillOval(x-20, y+10, 20, 20);
                break;
        }
    }
}
